/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.weeego.web.action;

import com.opensymphony.xwork2.ActionContext;
import com.sql.weeego.bean.base.CenterUser;
import com.weeego.web.base.BaseAction;
import java.util.Map;

/**
 *
 * @author zuaa
 */
public class AdminLoginAction extends BaseAction {

    private String name;
    private String psw;
    private String email;

    public AdminLoginAction() {
        super();
        this.objectForm = new CenterUser(name, psw, email);
        logger.info((CenterUser) objectForm);
    }

    @Override
    public String action() {
        if (getAct() == 1) {
            //login
            if ((this.service.findByHql(" from CenterUser t where t.name = '" +
                    name + "' and t.psw =  '" + psw + "'")).size() > 0) {
                this.commondResult = "1";
                CenterUser _CenterUser = (CenterUser) this.service.findObjectByHql("from CenterUser t where t.name like  '" + this.name + "'");
                Map session = ActionContext.getContext().getSession();
                session.put("user", _CenterUser);
            } else {
                this.commondResult = "0";
            }
            return SUCCESS;
        } else if (getAct() == 2) {
        }





        return ERROR;
    }

    public String getName() {
        return name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPsw() {
        return psw;
    }

    public void setPsw(String psw) {
        this.psw = psw;
    }

    public void setName(String name) {
        this.name = name;
    }
}
